package material.command.party;

import material.command.receiver_命令接收者.Hottub;
import material.command.receiver_命令接收者.Light;
import material.command.receiver_命令接收者.Stereo;
import material.command.receiver_命令接收者.TV;

public class RemoteLoader {
    public static void main(String[] args) {
        /**创建命令接收对象**/
        Light light = new Light("卧室");
        TV tv = new TV("卧室");
        Stereo stereo = new Stereo("卧室");
        Hottub hottub = new Hottub();
        /**创建具体的命令**/
        LightOnCommand lightOn = new LightOnCommand(light);
        StereoOnCommand stereoOn = new StereoOnCommand(stereo);
        TVOnCommand tvOn = new TVOnCommand(tv);
        HottubOnCommand hottubOn = new HottubOnCommand(hottub);
        LightOffCommand lightOff = new LightOffCommand(light);
        StereoOffCommand stereoOff = new StereoOffCommand(stereo);
        TVOffCommand tvOff = new TVOffCommand(tv);
        HottubOffCommand hottubOff = new HottubOffCommand(hottub);
        /**接下来创建两个数组，其中一个用来记录开启命令，
         * 另一个用来记录关闭命令，并在数组内放入对应的命令**/
        Command[] partyOn = {lightOn, stereoOn, tvOn, hottubOn};
        Command[] partyOff = {lightOff, stereoOff, tvOff, hottubOff};
        /**将指令数组放在命令的宏定义中**/
        MacroCommand partyOnMacro = new MacroCommand(partyOn);
        MacroCommand partyOffMacro = new MacroCommand(partyOff);
        /*创建遥控器*/
        RemoteControl remoteControl = new RemoteControl();
        /**将指令放在遥控器的卡槽**/
        remoteControl.setCommand(0, partyOnMacro, partyOffMacro);
        System.out.println("---------------------启动---------------------");
        remoteControl.onButtonWasPushed(0);
        System.out.println("---------------------关闭---------------------");
        remoteControl.offButtonWasPushed(0);
    }
}
